#pragma once

#include <QTcpSocket>
#include <QString>
#include <QHostAddress>

class TCPClient : public QObject
{
    Q_OBJECT
public:
    TCPClient(QObject* parent = nullptr);

    void setHost(const QString& ip, const quint16& port);
    bool send_read_file_lists(const QString& dir);
    bool send_copy_file(const QString& filename, const QString& sourceDir, const QString& destDir);

private:
    bool send_copy_file_inter();

Q_SIGNALS:
    void receive_read_file_lists(const QString& buf);
    void receive_copy_file(const bool successful);

private:
    QTcpSocket* m_socket;
    bool m_first = false;
    QHostAddress m_ip;
    quint16 m_port;
    QByteArray m_filebuf;
    qlonglong m_recvSize;
    qlonglong m_fileSize;
    QString m_filename;
    QString m_sourceDir;
    QString m_destDir;
};
